#include <limits>
void dfs(vector<int> &A, int X, int Y, int cost, int pos, long long total, int& min_cost){
    
    if(total <=0){
        min_cost = min(min_cost, cost);
        return;
    }
    if(pos >= A.size()){
        return;
    }
    total -= A[pos]*2;
    cost += Y;
    dfs(A, X, Y, cost, pos+1, total, min_cost);
    total += A[pos];
    cost -= Y;
    cost += X;
    dfs(A, X, Y, cost, pos+1, total, min_cost);
}


int solution(vector<int> &A, int X, int Y) {
    // write your code in C++14 (g++ 6.2.0)
    sort(A.begin(), A.end(), greater<int>());

    long long total = 0;
    for(auto it: A){
        total += it;
    }
    int cost = INT_MAX;
    auto temp = total;
    dfs(A, X, Y, 0, 0, total, cost);
    return cost
}